﻿<%@ Page Language="C#" MasterPageFile="~/Masterpages/Default.master" AutoEventWireup="true" CodeBehind="ManageAssets.aspx.cs" Inherits="Blazing.UI.Cms.Admin.ManageAssets" Title="Manage Assets" %>

<%@ Register Assembly="System.BusinessObjects.Framework" Namespace="System.BusinessObjects.Controls"
    TagPrefix="cc1" %>
<%@ Register Src="../Usercontrols/Loading.ascx" TagName="Loading" TagPrefix="uc3" %>
<%@ Register Assembly="System.Web.Extensions" Namespace="System.Web.UI" TagPrefix="asp" %>
<%@ Register src="../Usercontrols/ObjectTagCloud.ascx" tagname="ObjectTagCloud" tagprefix="uc1" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">     
   
        <table width="100%">
            <tr>
                <td style="vertical-align:top" valign="top">
                    <h1>Manage Assets</h1> 
                    <div class="grid">            
                        <div class="rounded">
                            <div class="top-outer">
                                <div class="top-inner">
                                    <div class="top">
                                    </div>
                                </div>
                            </div>               
                            <div class="mid-outer">
                                <div class="mid-inner">
                                    <div class="mid">
                                        <asp:Label ID="LabelDirectory" runat="server"/>
                                        <asp:TreeView ID="TreeViewDirectories" OnSelectedNodeChanged="TreeViewDirectories_SelectedNodeChanged" runat="server"/>
                                        <br /><br />
                                        <asp:LinkButton ID="LinkButtonShowDirectory" runat="server" Text="Add Directory"/>
                                        <ajax:ModalPopupExtender ID="ModalPopupExtender2" runat="server" BackgroundCssClass="PopupPanel"
                                            DropShadow="true" PopupControlID="PanelAddDirectory" PopupDragHandleControlID="PanelAddDirectoryTitle"
                                            TargetControlID="LinkButtonShowDirectory" CancelControlID="ButtonCancelDirectory">
                                        </ajax:ModalPopupExtender>
                                        <asp:Panel ID="PanelAddDirectory" runat="server" CssClass="PopupPanel">
                                            <div class="PopupPanelInner" style="width: 300px;">                                    
                                                <asp:Panel ID="PanelAddDirectoryTitle" runat="server" CssClass="PopupTitle">
                                                    Add Directory</asp:Panel>
                                                <asp:Panel ID="PanelAddDirectoryContent" runat="server" CssClass="PopupPanelInner">                                                
                                                    Enter New Directory Name: 
                                                    <asp:TextBox ID="TextBoxDirectoryName" runat="server"></asp:TextBox>
                                                    <br /><br />
                                                    <asp:Button ID="ButtonCreateDirectory" runat="server" Text="Create" OnClick="ButtonCreateDirectory_Click" /> 
                                                    <asp:Button ID="ButtonCancelDirectory" runat="server" Text="Cancel" />
                                                </asp:Panel>
                                            </div>
                                        </asp:Panel>
                                     </div>
                                 </div>
                             </div>
                             <div class="bottom-outer">
                                <div class="bottom-inner">
                                    <div class="bottom">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </td>
                <td style="vertical-align:top" valign="top">
                    <h1>Add Assets</h1>                                 
                    <div class="grid">            
                        <div class="rounded">
                            <div class="top-outer">
                                <div class="top-inner">
                                    <div class="top">
                                    </div>
                                </div>
                            </div>               
                            <div class="mid-outer">
                                <div class="mid-inner">
                                    <div class="mid">                            
                                        <div style="text-align:center">
                                            <asp:Label ID="LabelMessage" runat="server"/>
                                            <asp:FileUpload ID="AssetUpload" runat="server" />                          
                                            <asp:Button ID="UploadButton" runat="server" Text="Upload" OnClick="UploadButton_Click"/><br /> 
                                        </div>
                                    </div>
                                </div>
                             </div>
                             <div class="bottom-outer">
                                <div class="bottom-inner">
                                    <div class="bottom">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="grid">            
                        <div class="rounded">
                            <div class="top-outer">
                                <div class="top-inner">
                                    <div class="top">
                                    </div>
                                </div>
                            </div>               
                            <div class="mid-outer">
                                <div class="mid-inner">
                                    <div class="mid">   
                                        <asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional"> 
                                            <ContentTemplate>                                        
                                                <asp:ListView ID="ListView1" runat="server" DataSourceID="odsAssets" 
                                                    onitemcommand="ListView1_ItemCommand" DataKeyNames="ID,RowState,RowStamp,FilePath,FileName,Name">
                                                    <LayoutTemplate>
                                                        <table class="gridview" cellpadding="0" cellspacing="0">
                                                            <tr class="gridheader">
                                                                <th></th>
                                                                <th>FilePath</th>
                                                                <th>FileName</th>
                                                                <th>Description</th>
                                                                <th>AssetType</th>
                                                                <th>Tags</th>
                                                                <th></th>
                                                                <th></th>
                                                            </tr>
                                                            <tr id="itemPlaceholder" runat="server" />
                                                        </table>           
                                                    </LayoutTemplate>
                                                <ItemTemplate>
                                                    <tr class='<%# Container.DataItemIndex % 2 == 0 ? "row" : "row alt" %>'>
                                                    <td class="command">
                                                        <asp:LinkButton ID="btnEdit" runat="server" Text="Edit" CommandName="Edit" />
                                                    </td>     
                                                    <td><%# Eval("FilePath")%></td>
                                                    <td><%# Eval("FileName") %></td>
                                                    <td><%# Eval("Description") ?? "nbsp;" %></td>                                               
                                                    <td><%# Eval("AssetType.Name") ?? "nbsp;" %></td>
                                                    <td>
                                                        <asp:Repeater ID="repeaterTags" runat="server" DataSource='<%# Bind("TaxonomyTags") %>'>
                                                            <ItemTemplate>
                                                                <span class="TagCloudItem"><strong><asp:Literal ID="Literal1" runat="server" Text='<%# Eval("Taxonomy.Name") %>'/>
                                                                :</strong> <asp:Literal ID="Literal2" runat="server" Text='<%# Eval("Tag.Name") %>' /></span>
                                                            </ItemTemplate>
                                                        </asp:Repeater>
                                                    </td>
                                                    <td>
                                                        <asp:Image ID="Image1" runat="server" ImageUrl='<%#"/Thumbnail.ashx?File=" + Eval("FilePath").ToString() + Eval("FileName").ToString() + "&Width=40&Height=40" %>' />  
                                                    </td>
                                                    <td class="command">
                                                        <asp:LinkButton ID="LinkButtonDelete" runat="server" Text="Delete" CommandName="Delete" />
                                                    </td>
                                                    </tr>    
                                                </ItemTemplate>
                                                <EditItemTemplate>                                
                                                    <tr class='edit-info'>
                                                        <td class="command">
                                                            <!--<asp:LinkButton ID="btnEdit" runat="server" Text="Edit" CommandName="Edit" />-->
                                                        </td>
                                                        <td><asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("FilePath") %>'></asp:TextBox></td>
                                                        <td><asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("FileName") %>'></asp:TextBox></td>
                                                        <td><asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox></td>
                                                        <td> <cc1:BindableDropDownListExtender ID="BindableDropDownListExtender1" runat="server"
                                                            AttachTo="ddlAssetTypeSelection" BoundValueType="Blazing.BusinessObjects.Assets.AssetType, Blazing.BusinessObjects"
                                                            BoundValue='<%# Bind("AssetType") %>' />
                                                        <asp:DropDownList ID="ddlAssetTypeSelection" runat="server" DataSourceID="odsAssetTypes" DataTextField="Name"
                                                            DataValueField="ID"></asp:DropDownList>
                                                        <asp:ObjectDataSource ID="odsAssetTypes" runat="server" DataObjectTypeName="Blazing.BusinessObjects.Assets.AssetType"
                                                            OldValuesParameterFormatString="original_{0}" SelectMethod="GetAssetTypes" TypeName="Blazing.WebFacade.AssetController">
                                                        </asp:ObjectDataSource></td>

                                                        <td></td> 
                                                        <td></td> 
                                                        <td></td>                                                                                                                                               
                                                    </tr>            
                                                    <tr>
                                                        <td class="edit" colspan="8">
                                                            <div class="details">
                                                                <div class="header">Edit</div>
                                                                <table class="detailview" cellpadding="0" cellspacing="0">                                                
                                                                    <tr>
                                                                        <td>
                                                                            <uc1:ObjectTagCloud ID="ObjectTagCloud1" runat="server" TaxonomyTags='<%# Bind("TaxonomyTags") %>' />                                   
                                                                        </td>
                                                                        <td align="right">
                                                                            <asp:Image ID="Image1" runat="server" ImageUrl='<%# "/Thumbnail.ashx?File=" + Eval("FilePath").ToString() + Eval("FileName").ToString() + "&Width=150&Height=150" %>' />     
                                                                             
                                                                             
                                                                            <asp:Panel ID="PanelCreateThumb" runat="server">
                                                                            Size <asp:TextBox ID="txtWidth" runat="server" Width="50" Text="50"></asp:TextBox> x <asp:TextBox ID="txtHeight" runat="server" Width="50" Text="50"></asp:TextBox>
                                                                            <asp:LinkButton ID="btnCreateThumb" runat="server" Text="Create Thumb" CommandName="Thumb" />
                                                                            </asp:Panel>
                                                                        </td>                                                                                                                                           
                                                                    </tr>                                                                                                                          
                                                                </table>
                                                                <div class="">
                                                                    <asp:LinkButton 
                                                                        ID="btnSave" runat="server" 
                                                                        Text="Save" CommandName="Update" 
                                                                    />
                                                                    <asp:LinkButton 
                                                                        ID="btnCancel" runat="server" 
                                                                        Text="Cancel" CommandName="Cancel" 
                                                                    />
                                                                </div>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </EditItemTemplate>                                                
                                            </asp:ListView>                       
                                        </ContentTemplate>                    
                                    </asp:UpdatePanel>
                                </div>
                            </div>
                            <div class="bottom-outer">
                                <div class="bottom-inner">
                                    <div class="bottom">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    </div> 
                </td>
            </tr>
        </table>      
        <br /><br />        
    <asp:ObjectDataSource ID="odsAssets" runat="server" DataObjectTypeName="Blazing.BusinessObjects.Assets.Asset"
        DeleteMethod="DeleteAsset" InsertMethod="NewAsset" OldValuesParameterFormatString="original_{0}"
        SelectMethod="GetAssets" TypeName="Blazing.WebFacade.AssetController"
        UpdateMethod="UpdateAsset">
        <SelectParameters>
            <asp:ControlParameter ControlID="TreeViewDirectories" Name="path" PropertyName="SelectedValue" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="odsAssetTypes" runat="server" OldValuesParameterFormatString="original_{0}"
        SelectMethod="GetAssetTypes" TypeName="Blazing.WebFacade.AssetController"/>                           
    <ajax:UpdateProgress runat="server" ID="update" DisplayAfter="0" AssociatedUpdatePanelID="updatePanel">
        <ProgressTemplate>
            <uc3:Loading ID="Loading1" runat="server" />
        </ProgressTemplate>
    </ajax:UpdateProgress>
</asp:Content>
